<template>
  <!-- 查询框 -->
  <a-card :bordered="false">
    <div class="table-page-search-wrapper">
      <a-spin :spinning="spanLoading">
        <a-form layout="inline" :form="form">
          <a-row :gutter="48">
            <a-col :md="6" :sm="24">
              <a-form-item label=券号>
                <a-input placeholder="请输入券号"
                  v-decorator="['voucherNo', {rules: [{ required: true, message: '请输入券号' }]}]" />
              </a-form-item>
            </a-col>
            <a-col :md="6" :sm="24">
              <span class="table-page-search-submitButtons">
                <a-button type="primary" @click="sendMessage">提交</a-button>
              </span>
            </a-col>
          </a-row>
        </a-form>
      </a-spin>
    </div>

  </a-card>
</template>
    
<script>
import { refundVoucher } from '@/api/operateTools/index'

export default {
  data() {
    return {
      form: this.$form.createForm(this),
      spanLoading: false
    }
  },
  methods: {
    //点击提交按钮
    sendMessage(e) {
      e.preventDefault()
      this.form.validateFields((err, values) => {
        if (!err) {
          this.spanLoading = true
          console.log('Received values of form: ', values)
          refundVoucher(values).then(res => {
            if (res.code === 200 && res.success === true) {
              if (res.data.ret === 1) {
                this.$success({
                  title: res.data.retmsg
                })
              } else if (res.data.ret === -1) {
                this.$warning({
                  title: res.data.retmsg
                })
              }
            } else {
              this.$error({
                title: res.msg,
              })
            }
            this.spanLoading = false
          })

        }
      })
    }

  },
  created() {

  }

}
</script>
    
<style scoped>

</style>